/**
 * 表格
 * */
layui.define(['treeTable', 'form'], (exports) => {
	let treeTable = layui.treeTable;
	let form = layui.form;
	
	let sdTreeTable = {
		init(configuration) {
			let tbId = (configuration.id).indexOf('#') >= 0 ? configuration.id : '#' + configuration.id;
			let tb = treeTable.render({
				elem: tbId,
				data: configuration.data,
				icon_key: 'title',
				end: function(e) {
					form.render();
				},
				cols: configuration.cols
			});
			// 监听时间
			$.each(configuration.btns, (i, o) => {
				let tbtn = 'tree(' + o.opt + ')';
				treeTable.on(tbtn, function(data) {
					o.event ? o.event(data.item) : ""
				})
			})
			return tb;
		},
		refresh(tb) {
			treeTable.render(tb);
		}
	}
	exports('sdTreeTable', sdTreeTable);
})
